package com.wangmei.service.serviceimpl;

import com.wangmei.mapper.ProductpicMapper;
import com.wangmei.model.Product;
import com.wangmei.model.Productpic;
import com.wangmei.pojo.ProductPicPojo;
import com.wangmei.service.ProductPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductPicServiceImpl implements ProductPicService {
    @Autowired
    public ProductpicMapper productpicMapper;


    @Override
    public List<Productpic> getProductAllPic(int pid) {
        return productpicMapper.getProductAllPic(pid);
    }

    @Override
    public List<ProductPicPojo> getPics() {
        return productpicMapper.selectpics();
    }

    @Override
    public int insertList(int pid, List<String> urls) {
        Productpic pic = new Productpic();
        for(int i = 0;i<urls.size();i++){
            pic = new Productpic();
            pic.setPid(pid);
            pic.setPicurl(urls.get(i));
            productpicMapper.insertSelective(pic);
        }
        return 0;
    }

    @Override
    public int insert(Productpic productpic) {
        return productpicMapper.insertSelective(productpic);
    }
}
